/**
 * Copyright (C) 2011 Andrew C. Love (DNC) <dnc.app.sup@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.dnc.cloak.framework.security.encryption;

import java.security.KeyStore;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.dnc.cloak.framework.persistence.gen.Keystore;
import com.dnc.cloak.framework.persistence.gen.KeystoreEntry;

public class KeystoreBean {
    private Keystore keystore;
    private KeyStore javaKeystore;
    private List<KeystoreEntry> keystoreEntries;
    private Map<String,KeystoreEntry> keystoreEntryMap;
    
    public KeystoreBean(Keystore keystore,
            List<KeystoreEntry> keystoreEntries,
            KeyStore javaKeystore) {
        super();
        this.keystore = keystore;
        this.keystoreEntries = keystoreEntries;
        this.javaKeystore = javaKeystore;
        
        keystoreEntryMap = Collections.synchronizedMap(new HashMap<String,KeystoreEntry>());  
        for (Iterator<KeystoreEntry> iterator = keystoreEntries.iterator(); iterator.hasNext();) {
            KeystoreEntry keystoreEntry = iterator.next();
            keystoreEntryMap.put(keystoreEntry.getKeystoreEntryAlias(), keystoreEntry);
        }
    }
    public Keystore getKeystore() {
        return keystore;
    }
    public void setKeystore(Keystore keystore) {
        this.keystore = keystore;
    }
    public List<KeystoreEntry> getKeystoreEntries() {
        return keystoreEntries;
    }
    public void setKeystoreEntries(List<KeystoreEntry> keystoreEntries) {
        this.keystoreEntries = keystoreEntries;
    }
    public KeyStore getJavaKeystore() {
        return javaKeystore;
    }
    public void setJavaKeystore(KeyStore javaKeystore) {
        this.javaKeystore = javaKeystore;
    }
    public Map<String, KeystoreEntry> getKeystoreEntryMap() {
        return keystoreEntryMap;
    }    
    

}
